home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
WarriorsProgress.sit
/
Warrior’s Progress
/
source code
/
Source
/
Libraries
/
Data
/
ConstData.cp
next >
Wrap
Text File
|
1997-06-28
|
2KB
|
90 lines
// ConstData.cp
#ifndef ConstData_h
#include "ConstData.h"
#endif
#ifndef MinMax_h
#include "MinMax.h"
#endif
bool ConstData::operator==( const ConstData& b ) const
{
if ( this->Length() != b.Length() )
return false;
for ( uint32 i = 0; i < this->Length(); i++ )
if ( (*this)[i] != b[i] )
return false;
return true;
}
bool ConstData::operator<( const ConstData& b ) const
{
uint32 matched = Min( this->Length(), b.Length() );
for ( uint32 i = 0; i < matched; i++ )
if ( (*this)[i] < b[i] )
return true;
return this->Length() < b.Length();
}
bool ConstData::operator<=( const ConstData& b ) const
{
uint32 matched = Min( this->Length(), b.Length() );
for ( uint32 i = 0; i < matched; i++ )
if ( (*this)[i] > b[i] )
return false;
return this->Length() <= b.Length();
}
bool ConstData::StartsWith( ConstData b ) const
{
if ( this->Length() < b.Length() )
return false;
for ( uint32 i = 0; i < b.Length(); i++ )
if ( (*this)[i] != b[i] )
return false;
return true;
}
bool ConstData::EndsWith( ConstData b ) const
{
if ( this->Length() < b.Length() )
return false;
for ( uint32 i = 0; i < b.Length(); i++ )
if ( (*this)[ Length() - b.Length() + i ] != b[i] )
return false;
return true;
}
int32 Compare( ConstData a, ConstData b )
{
uint32 matched = Min( a.Length(), b.Length() );
for ( uint32 i = 0; i < matched; i++ )
{
int32 comparison = int32(a[i]) - int32(b[i]);
if ( comparison != 0 )
return comparison;
}
if ( a.Length() < b.Length() )
return -1;
if ( a.Length() > b.Length() )
return 1;
return 0;
}
#include "ConstArrayOf.cp"
template class ConstArrayOf<uint8>;